package com.dlc.apk.entity

/**
 * 换电仓
 */
data class BatteryBox(val targetAddress: Int/*所在仓控板地址*/, val num: Int/*电池仓编号*/) {
    var state: Int = 0//BIT0: 0:  通信正常，1：通信异常 其他：保留
    var workState: Int =
        0//工作状态 BIT0: 0:  仓门关闭，1：仓门打开 BIT1: 0:  无电池， 1：有电池 BIT2: 0:  电池通信正常，1：电池通信异常 BIT3: 0:  未充电， 1: 正在充电 BIT4: 0:  灭火装置未启动，1: 灭火装置启动 BIT5: 0:  电池没有升级，可以租借，1：电池升级不能租借 BIT6：0:  48V电池，1:60V电池 BIT7：0： 电池正常，1：电池异常，异常代码参见BMS异
    var temperature: Int = 0//仓内温度值 有符号数，单位为1度；范围-127°到127°C
    var batteryId: String? = ""//电池ID
    var remain: Int = 0//剩余电量的百分比，范围0-100
    var maxTemperature: Int = 0//最大温度
    var maxTemperatureBattery: Int = 0//最大温度电池序号
    var minTemperature: Int = 0//最小温度
    var minTemperatureBattery: Int = 0//最小温度电池序号
    var totalVoltage: Int = 0//总电压
    var totalCurrent: Int = 0//总电流
    var maxVoltage: Int = 0//最大电压
    var maxVoltageBattery: Int = 0//最大电压序号
    var minVoltage: Int = 0//最小电压
    var minVoltageBattery: Int = 0//最小电压序号
    var bmsErrCode: Int = 0//0x00：电池正常 其他：异常，待定义

    //工作状态数据解析到bean
    var workStateInfo: WorkStateInfo? = null

    override fun equals(other: Any?): Boolean {
        return super.equals(other)
    }

    override fun toString(): String {
        return "BatteryBox(targetAddress=$targetAddress, num=$num, state=$state, workState=$workState, temperature=$temperature, batteryId=$batteryId, remain=$remain, maxTemperature=$maxTemperature, maxTemperatureBattery=$maxTemperatureBattery, minTemperature=$minTemperature, minTemperatureBattery=$minTemperatureBattery, totalVoltage=$totalVoltage, totalCurrent=$totalCurrent, maxVoltage=$maxVoltage, maxVoltageBattery=$maxVoltageBattery, minVoltage=$minVoltage, minVoltageBattery=$minVoltageBattery, bmsErrCode=$bmsErrCode, workStateInfo=$workStateInfo)"
    }
}

data class WorkStateInfo(
    var doorStatus: Int = 0,/*仓门关闭/打开  BIT0: 0:  仓门关闭，1：仓门打开*/
    var hasBattery: Int = 0, //有无电池 BIT1: 0:  无电池， 1：有电池
    var communicationStatus: Int = 0, //0:  电池通信正常，1：电池通信异常
    var chargeStatus: Int = 0, //0:  未充电， 1: 正在充电
    var outfireStatus: Int = 0, // 灭火装置未启动，1: 灭火装置启动
    var upgradeStatus: Int = 0,//0:  电池没有升级，可以租借，1：电池升级不能租借
    var voltage: Int = 0,//0:  48V电池，1:60V电池
    var status: Int = 0,//0： 电池正常，1：电池异常，异常代码参见BMS异常
) {

    companion object {
        const val DOOR_STATUS_CLOSED = 0
        const val DOOR_STATUS_OPENED = 1
    }

    override fun toString(): String {
        return "WorkStateInfo(doorStatus=$doorStatus, hasBattery=$hasBattery, communicationStatus=$communicationStatus, chargeStatus=$chargeStatus, outfireStatus=$outfireStatus, upgradeStatus=$upgradeStatus, voltage=$voltage, status=$status)"
    }
}